/* airCondBoxMib.c - IDB+ Module source for airCondBoxMib.mi2. */

/* Copyright 2013 Wind River, Inc. */
// #include "copyright_wrs.h"

/*
modification history
--------------------
xxx,22Mar13,idb Created by IDBGEN. Ver 2.28
%%BeginUserCode airCondBoxMib_Modifications
%%EndUserCode   airCondBoxMib_Modifications
*/

/*
DESCRIPTION
This module defines the IDB+ structures and IDB+ Object handler routines to
access the IDB+ objects defined in airCondBoxMib.mi2.

INCLUDE FILES: airCondBoxMib.h
*/

/* Includes */

#include "neos_vx_win.h"
#include "jialianMib_function.h"
#include "idbLib.h"
#include "airCondBoxMib.h"


/* %%BeginUserCode airCondBoxMib_IncludeFiles */
/* %%EndUserCode   airCondBoxMib_IncludeFiles */

/* Defines */
/* %%BeginUserCode airCondBoxMib_Defines */
/* %%EndUserCode   airCondBoxMib_Defines */

/* Globals */
/* %%BeginUserCode airCondBoxMib_Globals */
/* %%EndUserCode   airCondBoxMib_Globals */

/* Locals */
LOCAL char * moduleName = "airCondBoxMib";
/* %%BeginUserCode airCondBoxMib_Locals */
/* %%EndUserCode   airCondBoxMib_Locals */

/* Prototypes */
LOCAL STATUS airCondBoxMibScalarHandler ( idbRequest_t request, idb_t * idb );

/* %%BeginUserCode airCondBoxMib_Prototypes */
/* %%EndUserCode   airCondBoxMib_Prototypes */


/****************************************************************************
* IDB+ Module Object Descriptors
*/

LOCAL idbObjDesc_t onOff_objDesc[] = {
  { onOff, 1, 4, /* localId=0  1.3.6.1.4.1.123456.1.17.1 */
    { 0, 0 }, IDB_Unsigned32, (IDB_READ|IDB_WRITE),
    (IDB_VALID), airCondBoxMibScalarHandler,
    (char *)0, "airCondBoxMib:onOff" },
  { 0 }
};

LOCAL idbObjDesc_t onOffStatus_objDesc[] = {
  { onOffStatus, 2, 4, /* localId=1  1.3.6.1.4.1.123456.1.17.2 */
    { 0, 0 }, IDB_Unsigned32, IDB_READ,
    (IDB_VALID), airCondBoxMibScalarHandler,
    (char *)0, "airCondBoxMib:onOffStatus" },
  { 0 }
};

LOCAL idbObjDesc_t settedTemperature_objDesc[] = {
  { settedTemperature, 3, 4, /* localId=2  1.3.6.1.4.1.123456.1.17.3 */
    { 0, 0 }, IDB_Unsigned32, (IDB_READ|IDB_WRITE),
    (IDB_VALID), airCondBoxMibScalarHandler,
    (char *)0, "airCondBoxMib:settedTemperature" },
  { 0 }
};

LOCAL idbObjDesc_t currentTemperature_objDesc[] = {
  { currentTemperature, 4, 4, /* localId=3  1.3.6.1.4.1.123456.1.17.4 */
    { 0, 0 }, IDB_Unsigned32, IDB_READ,
    (IDB_VALID), airCondBoxMibScalarHandler,
    (char *)0, "airCondBoxMib:currentTemperature" },
  { 0 }
};

/*****************************************************************************
* IDB+ Module OID Table
*
* The OID list below (e.g.,{1,3,6,1, ...}) is the OID prefix minus the
* last sub-identifier.  The last sub-identifier is found in the
* object descriptor idbObjDesc_t structure.
*/

LOCAL idbOidTable_t oidTable[] = {
  /*   0: Scalar Object -- onOff */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,17}, 10,   /*lint !e785 */
    0, 1, { 0 },
    onOff_objDesc },

  /*   1: Scalar Object -- onOffStatus */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,17}, 10,   /*lint !e785 */
    0, 1, { 0 },
    onOffStatus_objDesc },

  /*   2: Scalar Object -- settedTemperature */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,17}, 10,   /*lint !e785 */
    0, 1, { 0 },
    settedTemperature_objDesc },

  /*   3: Scalar Object -- currentTemperature */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,17}, 10,   /*lint !e785 */
    0, 1, { 0 },
    currentTemperature_objDesc },

  { IDB_TERMINATOR }
};

/*****************************************************************************
* IDB+ Module Translate Table
*/

LOCAL idbXlateTable_t xlateTable[] = {
    { &oidTable[  0], &onOff_objDesc[0] },
    { &oidTable[  1], &onOffStatus_objDesc[0] },
    { &oidTable[  2], &settedTemperature_objDesc[0] },
    { &oidTable[  3], &currentTemperature_objDesc[0] },

    { 0 }
};

/******************************************************************************
* User Local Functions.
*/

/* %%BeginUserCode airCondBoxMib_UserFunctions */
/* %%EndUserCode   airCondBoxMib_UserFunctions */


/****************************************************************************
*
* airCondBoxMibInit - initialize/register airCondBoxMib and objects.
*
* This routine initializes the modules IDB routines.
*
* RETURNS: SNMP_OK or SNMP_ERROR
*
* ERRNO: N/A
*/

STATUS airCondBoxMibInit
    (
    void * parm1,
    void * parm2
    )
    {
    STATUS    rc;

    /* %%BeginUserCode airCondBoxMibInit_Prolog */
    /* %%EndUserCode   airCondBoxMibInit_Prolog */

    rc = SNMP_OK;

    /* %%BeginUserCode airCondBoxMibInit_Body */
    /* %%EndUserCode airCondBoxMibInit_Body */

    /* Register the module's information with IDB+ engine */
    rc = idbModuleRegister( moduleName, &xlateTable[0] );

    /* %%BeginUserCode airCondBoxMibInit_Epilog */
    /* %%EndUserCode   airCondBoxMibInit_Epilog */

    return( rc );
    }

/******************************************************************************
*
* airCondBoxMibTerminate - Terminate airCondBoxMib and objects.
*
* This routine de-initializes the IDB module functions.
*
* RETURNS: SNMP_OK or SNMP_ERROR
*
* ERRNO: N/A
*/

STATUS airCondBoxMibTerminate
    (
    void * parm
    )
    {
    STATUS    rc;

    /* %%BeginUserCode airCondBoxMibTerminate_Prolog */
    /* %%EndUserCode   airCondBoxMibTerminate_Prolog */

    rc = SNMP_OK;

    /* De-register the module's information with IDB+ engine */
    idbModuleDeRegister( moduleName );

    /* %%BeginUserCode airCondBoxMibTerminate_Epilog */
    /* %%EndUserCode   airCondBoxMibTerminate_Epilog */

    return( rc );
    }

/******************************************************************************
*
* airCondBoxMibScalarHandler - handles all scalar objects.
*
* This routine handles all scalar objects for this IDB+ Module.
*
* RETURNS: SNMP_OK or SNMP_ERROR
*
* ERRNO: N/A
*/

LOCAL STATUS airCondBoxMibScalarHandler
    (
    idbRequest_t request,
    idb_t * idb
    )
    {
    STATUS    rc;

    /* %%BeginUserCode airCondBoxMibScalarHandler_Prolog */
    /* %%EndUserCode   airCondBoxMibScalarhandler_Prolog */

    rc = SNMP_OK;

    /* Validate the Scalar indexSubIdCount and instance value */
    if ( idbScalarValidate( request, idb ) == SNMP_ERROR )
        return idbErrorRequestMap( request );

    switch( idb->localId )
    {
    default:
        rc = idbErrorNoSuchInstance();
        break;

    /* ================================================================= */
    case onOff:    /* Unsigned32, read-write */
        {
        /* %%BeginUserCode onOff_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:

			rc = jilian_demo_get ((UINT32 *)(idb->pValueBuf));
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
        case IDB_COMMIT:
			rc=jilian_demo_set((UINT32*)(idb->pValueBuf));
            break;
        }

        /* %%EndUserCode   onOff_Body */
        }
        break;

    /* ================================================================= */
    case onOffStatus:    /* Unsigned32, read-only */
        {
        /* %%BeginUserCode onOffStatus_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:
            break;
        }

        /* %%EndUserCode   onOffStatus_Body */
        }
        break;

    /* ================================================================= */
    case settedTemperature:    /* Unsigned32, read-write */
        {
        /* %%BeginUserCode settedTemperature_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
        case IDB_COMMIT:
			rc=jilian_demo_set((UINT32*)(idb->pValueBuf));
            break;
        }

        /* %%EndUserCode   settedTemperature_Body */
        }
        break;

    /* ================================================================= */
    case currentTemperature:    /* Unsigned32, read-only */
        {
        /* %%BeginUserCode currentTemperature_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:
            break;
        }

        /* %%EndUserCode   currentTemperature_Body */
        }
        break;

    }

    /* %%BeginUserCode airCondBoxMibScalar_Epilog */
    /* %%EndUserCode   airCondBoxMibScalar_Epilog */

    return( rc );
    }

